package cn.duxiaod.demo.singleton;

/**
 * 枚举实现单例模式
 */
public enum EnumSingletonClass {
    INSTANCE;
    EnumSingletonClass(){
        age = 23;
    }
    private int age;

    public static EnumSingletonClass getInstance() {
        return INSTANCE;
    }

    public int getAge() {
        return age;
    }

    public static void main(String[] args) {
        EnumSingletonClass instance = EnumSingletonClass.getInstance();
        EnumSingletonClass instance2 = EnumSingletonClass.getInstance();
        System.out.println(instance == instance2);
    }
}
